About View Ports, View Devices, and View Groups
The view-related objects in QuickDraw GX exist to support drawing. They work together to provide device-independent drawing destinations for an application, while at the same time allowing access to device characteristics and permitting drawing destinations and devices to be grouped and manipulated in flexible ways.These are the view-related objects:
Figure 7-1 shows the relationships among the view-related objects and the sequence of events that occur when a shape is drawn.
- View port. A view port represents a drawing destination, such as the content area within a window. View port objects are device-independent, and have mapping and clipping properties that position, modify, and mask the shapes drawn into them. A shape's transform object defines the view ports that the shape is drawn into.
- View device. A view device represents a physical device, such as a monitor or printer, on which objects are drawn. Each view device object has mapping and clipping properties that define its resolution, mask its visible area, and position it in relation to view ports and other view devices.
- View group. A view group relates view ports and view devices to each other. Each view group object identifies a particular set of view ports and view devices; it also defines a coordinate space that positions view ports and view devices relative to each other. Drawing occurs in those locations where view ports and view devices within the same view group overlap.
Figure 7-1 Objects used by the drawing mechanism
As Figure 7-1 shows, a shape's geometry, initially modified by information contained in the shape's style object and ink object, is further modified by the clip and the mapping of the transform object. That modified shape is then even further modified by the mapping and clip of one or more view ports, and modified once more by the mapping and clip of any view devices that intersect the view ports.
A shape cannot be drawn unless its transform object contains a reference to at least one view port. The transform object for the shape in Figure 7-1 references only one view port, so the shape is drawn only once. Transform objects are described in the chapter "Transform Objects" in this book.
Drawing occurs where the clip of a view port overlaps the clip of a view device within the same view group. The overlap is determined by the dimensions of the two clip shapes, both of which are defined in terms of the view group's coordinate space. In this example, the position of the shape in the view port and the overlap between the view port and the view device mean that only part of the shape is rendered.
The view group in Figure 7-1 represents a coordinate space for all view ports and view devices that may be visible to the user of your application. This particular view group is called the onscreen view group because the view devices represent actual screen devices. You can create view groups to draw offscreen as well.
View-related objects are different from most other QuickDraw GX objects in several ways:
- All the view-related objects can be shared, but they have no owner count and cannot be cloned. When you dispose of a view-related object, it is deleted from memory.
- View ports can be arranged hierarchically, and you can attach a view port hierarchy to a Macintosh window to simplify clipping, moving, and scrolling documents in a window.
- QuickDraw GX creates view device objects for all physical screen devices for you; for drawing to the screen, you normally never need to create a new view device.